<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorate="body/main">
<head>
    <meta charset="UTF-8">
    <title>修改</title>
</head>
<body>
<div class="right_col" role="main" layout:fragment="content">
    <div class="">
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>编辑客户信息 <i class="fa fa-user"></i><small th:text="${session.loginUser.usrName }">用户名</small></h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <div class="clearfix"></div>
                        <form class="form-horizontal form-label-left" th:action="@{/api/customer/editCustomerEdit}" action="" method="post" enctype="multipart/form-data">
                            <input type="hidden" th:value="${cstCustomer.custManagerId}" name="custManagerId" id="custManagerId">
                            <input type="hidden" id="custLevelLabel" name="custLevelLabel">
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custName">客户名称 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custName" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custName"  required="required"
                                           placeholder="请输入客户名称" type="text" th:value="${cstCustomer.custName}" >
                                </div>
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custNo">客户编号 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custNo" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custNo"  required="required"
                                           placeholder="请输入客户编号" type="text" th:value="${cstCustomer.custNo}">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custRegion">地区 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <select name="custRegion" class="form-control" id="custRegion">
                                        <option value=""></option>
                                    </select>
                                </div>
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custManagerName">负责人 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custManagerName" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custManagerName"  required="required"
                                           placeholder="请输入负责人名称" type="text" th:value="${cstCustomer.custManagerName}">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custLevel">客户等级 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <select name="custLevel" class="form-control" id="custLevel">
                                        <option value=""></option>
                                    </select>
                                </div>
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custCredit">客户信誉度 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <select name="custCredit" class="form-control" id="custCredit">
                                        <option value="1" th:if="${cstCustomer.custCredit == 1}" selected="selected">⭐</option>
                                        <option value="1" th:if="${cstCustomer.custCredit != 1}">⭐</option>

                                        <option value="2" th:if="${cstCustomer.custCredit == 2}" selected="selected">⭐⭐</option>
                                        <option value="2" th:if="${cstCustomer.custCredit != 2}">⭐⭐</option>

                                        <option value="3" th:if="${cstCustomer.custCredit == 3}" selected="selected">⭐⭐⭐</option>
                                        <option value="3" th:if="${cstCustomer.custCredit != 3}">⭐⭐⭐</option>

                                        <option value="4" th:if="${cstCustomer.custCredit == 4}" selected="selected">⭐⭐⭐⭐</option>
                                        <option value="4" th:if="${cstCustomer.custCredit != 4}">⭐⭐⭐⭐</option>

                                        <option value="5" th:if="${cstCustomer.custCredit == 5}" selected="selected">⭐⭐⭐⭐⭐</option>
                                        <option value="5" th:if="${cstCustomer.custCredit != 5}">⭐⭐⭐⭐⭐</option>
                                    </select>
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custSatisfy">客户满意度 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <select name="custSatisfy" class="form-control" id="custSatisfy">
                                        <option value="1" th:if="${cstCustomer.custSatisfy == 1}" selected="selected">⭐</option>
                                        <option value="1" th:if="${cstCustomer.custSatisfy != 1}">⭐</option>

                                        <option value="2" th:if="${cstCustomer.custSatisfy == 2}" selected="selected">⭐⭐</option>
                                        <option value="2" th:if="${cstCustomer.custSatisfy != 2}">⭐⭐</option>

                                        <option value="3" th:if="${cstCustomer.custSatisfy == 3}" selected="selected">⭐⭐⭐</option>
                                        <option value="3" th:if="${cstCustomer.custSatisfy != 3}">⭐⭐⭐</option>

                                        <option value="4" th:if="${cstCustomer.custSatisfy == 4}" selected="selected">⭐⭐⭐⭐</option>
                                        <option value="4" th:if="${cstCustomer.custSatisfy != 4}">⭐⭐⭐⭐</option>

                                        <option value="5" th:if="${cstCustomer.custSatisfy == 5}" selected="selected">⭐⭐⭐⭐⭐</option>
                                        <option value="5" th:if="${cstCustomer.custSatisfy != 5}">⭐⭐⭐⭐⭐</option>
                                    </select>
                                </div>
                            </div>
                            <br/>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custAddr">地址 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custAddr" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custAddr"  required="required"
                                           placeholder="请输入客户地址" type="text" th:value="${cstCustomer.custAddr}">
                                </div>
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custZip">邮政编码 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custZip" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custZip"  required="required"
                                           placeholder="请输入邮政编码" type="text" th:value="${cstCustomer.custZip}">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custTel">电话 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custTel" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custTel"  required="required"
                                           placeholder="请输入客户电话" type="text" th:value="${cstCustomer.custTel}">
                                </div>
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custFax">传真 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custFax" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custFax"  required="required"
                                           placeholder="请输入客户传真" type="text" th:value="${cstCustomer.custFax}">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custWebsite">网址 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custWebsite" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custWebsite"  required="required"
                                           placeholder="请输入客户网址" type="text" th:value="${cstCustomer.custWebsite}">
                                </div>
                            </div>

                            <br/>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custLicenceNo">营业执照注册号 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custLicenceNo" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custLicenceNo"  required="required"
                                           placeholder="请输入营业执照注册号" type="text" th:value="${cstCustomer.custLicenceNo}">
                                </div>
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custChieftain">法人 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custChieftain" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custChieftain"  required="required"
                                           placeholder="请输入客户法人" type="text" th:value="${cstCustomer.custChieftain}">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custBankroll">注册资金(万元)
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custBankroll" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custBankroll"
                                           placeholder="请输入注册资金" type="text" th:value="${cstCustomer.custBankroll}">
                                </div>
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custTurnover">年营业额
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custTurnover" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custTurnover"
                                           placeholder="请输入客户年营业额" type="text" th:value="${cstCustomer.custTurnover}">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custBank">开户银行 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custBank" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custBank"  required="required"
                                           placeholder="请输入开户银行" type="text" th:value="${cstCustomer.custBank}">
                                </div>
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custBankAccount">银行账号 <span class="required">*</span>
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custBankAccount" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custBankAccount"  required="required"
                                           placeholder="请输入客户银行账号" type="text" th:value="${cstCustomer.custBankAccount}">
                                </div>
                            </div>
                            <div class="item form-group">
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custLocalTaxNo">地税登记号
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custLocalTaxNo" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custLocalTaxNo"
                                           placeholder="请输入客户地税登记号" type="text" th:value="${cstCustomer.custLocalTaxNo}">
                                </div>
                                <label class="control-label col-md-2 col-sm-2 col-xs-12" for="custNationalTaxNo">国税登记号
                                </label>
                                <div class="col-md-3 col-sm-3 col-xs-12">
                                    <input id="custNationalTaxNo" class="form-control col-md-5 col-xs-12"
                                           data-validate-length-range="20" data-validate-words="1" name="custNationalTaxNo"
                                           placeholder="请输入客户国税登记号" type="text" th:value="${cstCustomer.custNationalTaxNo}">
                                </div>
                            </div>

                            <div class="ln_solid"></div>
                            <div class="form-group">
                                <div class="col-md-9 col-md-offset-5">
                                    <button id="send" type="submit" class="btn btn-success">保存</button>
                                    <button type="button" class="btn btn-primary" id="back" onclick="history.back()">返回</button>
                                    <br/><br/>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script layout:fragment="js" th:inline="javascript">
    $(document).ready(function (){
        $.ajax({
            type:"GET",
            url:"/crm/api/common/findAll",
            data:"dictType=地区",
            success:function (data){
                $("#custRegion").html("");
                var custRegion = [[${cstCustomer.custRegion}]];
                var options = "";
                for(var i = 0; i < data.length; i++){
                    if(custRegion != null && custRegion != undefined && data[i].dictItem == custRegion){
                        options += "<option selected=\"selected\" value=\""+data[i].dictItem+"\" >"+data[i].dictItem+"</option>";
                    }else{
                        options += "<option value=\""+data[i].dictItem+"\" >"+data[i].dictItem+"</option>";
                    }
                }
                $("#custRegion").html(options);
            },
            error:function (data){
                alert("对不起，获取数据失败！");
            }
        })
        $.ajax({
            type:"GET",
            url:"/crm/api/common/findAll",
            data:"dictType=客户等级",
            success:function (data){
                $("#custLevel").html("");
                var custLevel = [[${cstCustomer.custLevel}]];
                var options = "";
                for(var i = 0; i < data.length; i++){
                    if(custLevel != null && custLevel != undefined && data[i].dictValue == custLevel){
                        options += "<option selected=\"selected\" value=\""+data[i].dictValue+"\" >"+data[i].dictItem+"</option>";
                        var custLevelLabel=document.getElementById("custLevelLabel");
                        custLevelLabel.value = data[i].dictItem;
                    }else{
                        options += "<option value=\""+data[i].dictValue+"\" >"+data[i].dictItem+"</option>";
                    }
                }
                $("#custLevel").html(options);
            },
            error:function (data){
                alert("对不起，获取数据失败！");
            }
        })
    });
    $("#custLevel").bind("change", function () {
        var option = $("#custLevel option:selected");
        var custLevelLabel=document.getElementById("custLevelLabel");
        custLevelLabel.value = option.text();
    });
</script>
</html>